/**
 * 实现数组的map方法
 */

function myMap<T, R>(arr: T[], callbackFn: (v: T) => R): R[] {
  const result: R[] = [];
  for (let i = 0; i < arr.length; i++) {
    result[i] = callbackFn(arr[i]);
  }

  return result;
}

// 测试
console.log(myMap([1, 2, 3], v => v * 2));
